class: center, middle, inverse, title-slide # Lecture 14 ## Models for Factorial Designs ### Psych 10 C ### University of California, Irvine ### 04/29/2022 --- ## Review - Last week we talked about factorial designs and the models that we use to analyze the results of such experiments. -- - Null model, assumes that the expected value of the dependent variable is the same regardless of values that a factor can take. -- - Main effects models, assume that only one factor has an effect on the expected value of the dependent variable. -- - Additive models assumed that 2 or more factors could have an effect on a participants' response, however, that effect is considered to be independent and therefore is equal to the sum of the main effects of each factor `\((\alpha\)` and `\(\beta)\)`. -- - Full model, which assumes that the expected value of the dependent variable is different for each group (combination of factor levels). Furthermore, this expectation can't be expressed as the sum of the independent main effects. --- ## Review - The prediction of the Null model in factorial designs is known as the grand mean, and it's the average of the responses of all participants regardless of the level of each factor that they where exposed to. `$$\hat{\mu}$$` -- - The predictions of the Main effects models were equal to the sum of the average response across all participants and the "effect" of the factor that defines each model. `$$\hat{\mu} + \hat{\alpha}_j$$` or `$$\hat{\mu} + \hat{\beta}_k$$` -- - For factor 1 or factor 2 respectively. --- # Error in lecture 12 - So... I made a mistake in lecture 12, and we should calculate the estimator `\(\hat{\alpha}_1\)` and `\(\hat{\beta}_1\)` using this equation: `$$\hat{\alpha}_1 = \hat{\mu}_{1\cdot} - \hat{\mu}$$` and `$$\hat{\beta}_1 = \hat{\mu}_{\cdot 1} - \hat{\mu}$$` -- - The interpretation is the same, it's the effect of being exposed to the *j-th* level of a factor. --- ## Review - We mentioned that using the estimates of the main effects `\(\hat{\alpha}_j\)` and `\(\hat{\beta}_k\)` we can derive the predictions of the additive model as: `$$\hat{\mu} + \hat{\alpha}_j + \hat{\beta}_k$$` -- - Finally, we mention that the predictions of the full model were equal to the average of our dependent variable for each combination of the levels of our factor: `$$\hat{\mu}_{jk} = \frac{1}{n_{jk}} \sum_i y_{ijk}$$` -- - Where `\(n_{jk}\)` represents the number of participants in the group that responded to the combination of the *j-th* and *k-th* values of factors 1 and 2 respectively. --- ## Cell means - The equations that we have seen in previous classes will always allow us to obtain the values of the parameters in each model. However, when we have a between subjects factorial design we can use the cell means method in order to obtain those values. -- - This method requires us to first calculate the average of each combination of the levels of our factors. -- - When we have a small number of participants on each group this is easy to do by hand. We will try this today. --- ## Cell means mehtod - First we need to introduce the problem that we want to solve. -- - We want to know if the cohort that a student belongs to or whether or not they took a statistics class during their first year have an effect on the anxiety levels they experience at the end of their first year. -- - In order to study whether our factors (cohort and having taken the statistics class) have an effect on the anxiety levels of students we asked them to respond to an anxiety scale. -- - Then we record whether they started college in 2019 or if they started in 2020 and whether they took a statistics class during their first year or not. -- - We collected information from a total of 16 participants for this study, 4 of which started college in 2019 and took a statistics class in their first year, 4 started college in 2019 and didn't take a statistics class, 4 started college in 2020 and took a statistics class and the remaining 4 started in 2020 and didn't take a statistics class during the first year. --- ## Anxiety data:
--- ## Anxiety example - Using the data from slide 7, obtain the cell means for the anxiety problem. Remember that the cell means are the predictions of the Full model, in other words, they are equal to the average of each combination of the factor levels. | | Statistics | Other | Mean | |----------|:---------------------:|:---------------------:|:--------------------:| | **2019** | `\(\hat{\mu}_{11}\)` | `\(\hat{\mu}_{12}\)` | | | **2020** | `\(\hat{\mu}_{21}\)` | `\(\hat{\mu}_{22}\)` | | | **Mean** | | | | - Fill in the following values with the correct average. <br> .pull-left[ | | Statistics | |------|:-----------:| | 2019 | .can-edit[] | | 2020 | .can-edit[] | ] .pull-right[ | | Other | |------|:-----------:| | 2019 | .can-edit[] | | 2020 | .can-edit[] | ] --- ## Anxiety example - After calculating the cell means, we can now calculate the mean by factor, for example, the mean of students in the 2019 cohort would be equal to the average of the values on the first row, and for the 2020 cohort it is equal to the values on the second row. | | Statistics | Other | Mean | |----------|:---------------------:|:----------------------:|:--------------------:| | **2019** | `\(\hat{\mu}_{11}\)` | `\(\hat{\mu}_{12}\)` | `\(\hat{\mu}_{1\cdot}\)` | | **2020** | `\(\hat{\mu}_{21}\)` | `\(\hat{\mu}_{22}\)` | `\(\hat{\mu}_{2\cdot}\)` | | **Mean** | `\(\hat{\mu}_{\cdot 1}\)` | `\(\hat{\mu}_{\cdot 2}\)` | | - Fill in the following values with the correct average. <br> .pull-left[ | | Mean | |------|:-----------:| | 2019 | .can-edit[] | | 2020 | .can-edit[] | ] .pull-right[ | | Mean | |------------|:-----------:| | Statistics | .can-edit[] | | Other | .can-edit[] | ] --- ## Anxiety example - Finally we can compute the grand mean by taking the average of the first cell means (the predictions of the full model). | | Statistics | Other | Mean | |----------|:---------------------:|:----------------------:|:--------------------:| | **2019** | `\(\hat{\mu}_{11}\)` | `\(\hat{\mu}_{12}\)` | `\(\hat{\mu}_{1\cdot}\)` | | **2020** | `\(\hat{\mu}_{21}\)` | `\(\hat{\mu}_{22}\)` | `\(\hat{\mu}_{2\cdot}\)` | | **Mean** | `\(\hat{\mu}_{\cdot 1}\)` | `\(\hat{\mu}_{\cdot 2}\)` | `\(\hat{\mu}\)` | - The grand mean was equal to : - `\(\hat{\mu}=\)` .can-edit[] --- ## Anxiety example - With the values that we have obtained we can now get the main effects `\(\hat{\alpha}_j\)` and `\(\hat{\beta}_k\)`. That way we will be able to get the predictions of the additive model. -- - To get the value of `\(\hat{\alpha}_1\)` remember that we need to get the difference between the average of the group and the grand mean. -- - Fill in the following table with the values of the main effects: | | Main effect | |------------------|:------------:| | `\(\hat{\alpha}_1\)` | .can-edit[] | | `\(\hat{\alpha}_2\)` | .can-edit[] | | `\(\hat{\beta}_1\)` | .can-edit[] | | `\(\hat{\beta}_2\)` | .can-edit[] | --- ## Predictions by model - What are the predicted anxiety levels of each model? -- - Null | Cohort | Class | Prediction | |:------:|:-----:|:-----------:| | 2019 | Stats | .can-edit[] | | 2019 | Other | .can-edit[] | | 2020 | Stats | .can-edit[] | | 2020 | Other | .can-edit[] | -- - Main effects Cohort | Cohort | Class | Prediction | |:------:|:-----:|:-----------:| | 2019 | Stats | .can-edit[] | | 2019 | Other | .can-edit[] | | 2020 | Stats | .can-edit[] | | 2020 | Other | .can-edit[] | --- ## Predictions by model - Main effects Class | Cohort | Class | Prediction | |:------:|:-----:|:-----------:| | 2019 | Stats | .can-edit[] | | 2019 | Other | .can-edit[] | | 2020 | Stats | .can-edit[] | | 2020 | Other | .can-edit[] | -- - Additive | Cohort | Class | Prediction | |:------:|:-----:|:-----------:| | 2019 | Stats | .can-edit[] | | 2019 | Other | .can-edit[] | | 2020 | Stats | .can-edit[] | | 2020 | Other | .can-edit[] | --- ## Predictions by model - Full | Cohort | Class | Prediction | |:------:|:-----:|:-----------:| | 2019 | Stats | .can-edit[] | | 2019 | Other | .can-edit[] | | 2020 | Stats | .can-edit[] | | 2020 | Other | .can-edit[] | --- ## Calculating the SSE - To calculate the SSE we just need to take each observation, subtract the prediction made by the model and then add all of the errors. The values are: | Model | SSE | |-----------|:-----------:| | Null | 95.75 | | ME Cohort | 46.75 | | ME Stats | 59.75 | | Additive | 10.75 | | Full | 10.5 | --- ## Mean Squared Error - Using the values on slide 16, compute the mean squared error (mse) of each model: | Model | Mean SE | |-----------|:-----------:| | Null | .can-edit[] | | ME Cohort | .can-edit[] | | ME Stats | .can-edit[] | | Additive | .can-edit[] | | Full | .can-edit[] | --- ## Model BIC - Using the Mean Squared Error we can calculate the BIC associated with each model. Remember that the value of `\(k\)` in the calculation of the BIC should be equal to the number of unknown values that we use to find a model's predictions: | Model | BIC | |-----------|:-----------:| | Null | .can-edit[] | | ME Cohort | .can-edit[] | | ME Stats | .can-edit[] | | Additive | .can-edit[] | | Full | .can-edit[] | --- ## Interpretation - Which of the models can better account for our data? - .can-edit[] -- - What can we conclude about our original research question? (effect of cohort and class) - .can-edit[] -- - How can we interpret the estimates of the model? - .can-edit[] --- ## Interpretation - We can also calculate the `\(R^2\)` value of the model that we choose and interpret it: - .can-edit[]